const app = getApp()

Page({
  data: {
    obj: [
      "请选择投诉对象",
      "其他业主",
      "物业工作人员",
      "小区事件"
    ],
    select: 0,
    description: '',
    date: '',
  },
  bindPickerChange(e){
    this.setData({
      select: e.detail.value
    })
  },
  bindDateChange(e){
    this.setData({
      date: e.detail.value
    })
  },
  formSubmit(e) {
    let that = this
    let data = {
      target: this.data.obj[this.data.select],
      content: e.detail.value.description,
      serviceTime: e.detail.value.date
    }
    app.sendPostRequest('/community/complain/', data, (res) => {
      // console.log(res)
      if(res.code == 200) {
        wx.showToast({
            title: '提交成功！',  
            icon: 'success',  
            duration: 1500
        })
        that.setData({
          select: 0,
          description: '',
          date: ''
        })
      } else {
        wx.showToast({
            title: '提交失败！',  
            icon: 'error',  
            duration: 1500
        })
      }
    }, (err) => {
      console.log(err.errMsg)
    })
  },
  onLoad: function (options) {
  }
})